import { useState } from 'react'
import PropTypes from 'prop-types'

const Child = (props) => {
  const [ncont] = useState(() => {
    if (props.initCount === 1) {
      return props.initCount + 2
    } else {
      return props.initCount + 5
    }
  })
  return (
    <div>
      子组件 props.initCount: {props.initCount}-ncont:{ncont}
    </div>
  )
}
Child.propTypes = {
  initCount: PropTypes.number.isRequired,
}
export default Child
